package com.zy.openchat.core.model.message;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;
import com.zy.openchat.core.manager.TelegramManager;

public class MessageSendingState implements Parcelable {
    //messageSendingStatePending
    //messageSendingStateFailed
    @SerializedName("@type")
    public String state;
    public int error_code;
    public String error_message;

    public TelegramManager.MessageSendState sendState() {
        if ("messageSendingStatePending".equals(state)) {
            return TelegramManager.MessageSendState.MessageSendState_Pending;
        }
        return TelegramManager.MessageSendState.MessageSendState_Fail;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.state);
        dest.writeInt(this.error_code);
        dest.writeString(this.error_message);
    }

    public MessageSendingState() {
    }

    protected MessageSendingState(Parcel in) {
        this.state = in.readString();
        this.error_code = in.readInt();
        this.error_message = in.readString();
    }

    public static final Creator<MessageSendingState> CREATOR = new Creator<MessageSendingState>() {
        @Override
        public MessageSendingState createFromParcel(Parcel source) {
            return new MessageSendingState(source);
        }

        @Override
        public MessageSendingState[] newArray(int size) {
            return new MessageSendingState[size];
        }
    };
}
